import logging

import pytest
from Tools.logger import logger
from Tools.Tools import ApiClient
from Tools.load_data import read_yaml
import requests
@pytest.fixture
def client():
    return ApiClient('http://47.113.229.131:9080/jeewms/')


class Test_WMS():
    @pytest.mark.parametrize('data1',read_yaml(r'C:\Users\张震海\Desktop\wms\Data\a.yaml'))
    def test_01(self,client,data1):
        logger()
        logging.info('begin')
        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': data1.get('userName'),
            'password': data1.get('password'),
            'randCode': '1670',  # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_02(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': '',
            'password': 'llg123',
            'randCode': '1670',  # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_03(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': 'admin',
            'password': '',
            'randCode': '1670',  # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_04(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': 'admin',
            'password': 'llg123',
            'randCode': '',  # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_05(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': '#####',
            'password': 'llg123',
            'randCode': '1670',  # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_06(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': 'admin',
            'password': '######',
            'randCode': '1670',  # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_07(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': 'admin',
            'password': 'llg123',
            'randCode': '@@@@@@@',  # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_08(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': 'admin',
            'password': 'llg123',
            'randCode': '1670',  # 验证码
            'langCode': 'zh-cn',

        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_09(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': 'admin',
            'password': 'llg123',
            'randCode': '1670',  # 验证码
            'langCode': 'zh-cn',
            'orgId': '',
            'id':'1'
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())

    def test_10(self,client):

        login_headers = {'content-type': 'application/x-www-form-urlencoded',
                         "Cookie": "JSESSIONID=C08CB798D329852787E93E4FBCECDA03"}
        data = {
            'userName': 'admin',
            'password': 'llg123',
            # 验证码
            'langCode': 'zh-cn',
            'orgId': ''
        }
        login = client.post(path='loginController.do?checkuser',data=data,headers=login_headers)

        print('登录接口响应:', login.json())
        logging.info('last')

if __name__ == '__main__':
    pytest.main()

